package com.jacen.fzxs.service.app.impl;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jacen.fzxs.entity.WallEntity;
import com.jacen.fzxs.entity.web.AppEntity;
import com.jacen.fzxs.entity.web.Wall;
import com.jacen.fzxs.exception.ParamException;
import com.jacen.fzxs.exception.WebException;
import com.jacen.fzxs.service.IWallService;
import com.jacen.fzxs.util.EntityUtils;

@Service
@Transactional(rollbackFor = Exception.class)
public class AddWallHandlerService extends BaseHandlerService {
	@Resource
	private IWallService wallService;

	@Override
	protected AppEntity submit(AppEntity appEntity,HttpServletRequest request) throws WebException {
		AppEntity resAppEntity = new AppEntity();
		Wall wall = appEntity.getWall();
		if(wall == null){
			throw new ParamException("墙体参数格式异常");
		}
		WallEntity entity = WallEntity.turnToWall(wall);
		try {
			entity.setId(EntityUtils.createId32());
			wallService.insert(entity);
		} catch (Exception e) {
			throw new WebException("添加墙体数据异常");
		}
		return resAppEntity;
	}

}
